package behavior.state;

/**
 * @author dali
 * @date 2021-07-28 13:58
 * @Description 上下文环境
 */

public class Context {
    private State state;
    Context() {
        state = new InitialState();
    }
    //set
    public void setState(State state) {
        this.state = state;
    }
    //启动
    public void start() throws Exception{
        state.start(this);
    }
    //获取时间片
    public void getCPU() throws Exception{
        state.getCPU(this);
    }
    //进行阻塞
    public void suspend() throws Exception{
        state.suspend(this);
    }
    //进行停止
    public void stop() throws Exception{
        state.stop(this);
    }
    //阻塞恢复
    public void resume() throws Exception{
        state.resume(this);
    }
}
